<template>
	<view class="padding-20">
		<view class="info" >
			<view class="not-logged-in" v-if="!isLogin" @tap="integrals">
				<text>注册解锁更多惊喜</text>
				<button type="primary" plain="true">注册/登录</button>
			</view>
			<view class="logged-in" v-else>
				<view class="flex align-center">
					<image class="avatar" :src="userInfo.avatarImage"/>
					<view class="ml-20">{{userInfo.mobile}}</view>
				</view>
				<view class="fisze-24 mt-20">
					<w-barcode :options="options" />
					<view class="mt-10 text-align-center">{{userInfo.number}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {mapState} from 'vuex'
	export default {
		data(){
			return {
				// options: {
				// 	width: 650,
				// 	height: 100,
				// 	code: ''
				// },
			}
		},
		computed: {
			...mapState(['userInfo', 'isLogin']),
			options(){
				return {
					width: 650,
					height: 100,
					code: this.userInfo.number
				}
			}
		},
		created() {
			// this.options.code = this.userInfo.number
		},
		methods: {
			integrals() {
				if(!this.isLogin) {
					uni.navigateTo({url: '/pages/login/login'})
				}
			}
		}
	}
	
</script>

<style lang="scss" scoped>
	.info {
		position: relative;
		border-radius: 10rpx;
		background-color: #ffffff;
		box-shadow: $box-shadow;
		padding: 30rpx;
		
		.not-logged-in{
			display: flex;
			justify-content: space-between;
			align-items: center;
		}
		
		.logged-in{
			.avatar{
				display: block;
				width: 80rpx;
				height: 80rpx;
				border-radius: 40rpx;
				background-color: $color-primary;
			}
		}
	}
	
</style>